/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.settlement.entity.investorcarcontract;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.sys.entity.Company;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 资方汽车供需合同Entity
 *
 * @author LV
 * @version 2021-03-06
 */
@Table(name = "t_investor_car_contract", alias = "a", columns = {
        @Column(name = "investor_car_contract_id", attrName = "investorCarContractId", label = "资方汽车供需合同ID", isPK = true),
        @Column(name = "investor_car_contract_code", attrName = "investorCarContractCode", label = "编号", queryType = QueryType.LIKE),
        @Column(name = "investor_id", attrName = "investorId", label = "资方"),
        @Column(name = "company_id", attrName = "companyId.companyCode", label = "代理公司"),
        @Column(name = "date", attrName = "date", label = "订单日期"),
        @Column(name = "remarks", attrName = "remarks", label = "备注", queryType = QueryType.LIKE),
        @Column(name = "create_by", attrName = "createBy", label = "创建者", isUpdate = false),
        @Column(name = "create_date", attrName = "createDate", label = "创建时间", isUpdate = false),
        @Column(name = "update_by", attrName = "updateBy", label = "更新者", isQuery = false),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
}, joinTable = {
        @JoinTable(type = Type.LEFT_JOIN, entity = Company.class, attrName = "companyId", alias = "u4",
                on = "u4.company_code = a.company_id", columns = {
                @Column(name = "company_code", label = "公司编码", isPK = true),
                @Column(name = "company_name", label = "公司名称"),
        }),
        @JoinTable(type = Type.LEFT_JOIN, entity = Supplier.class, attrName = "invSupplier", alias = "b",
                on = "b.supplier_id = a.investor_id", columns = {
                @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                @Column(name = "supplier_name", label = "供应商名称"),
        }),
}, orderBy = "a.update_date DESC"
)
public class InvestorCarContract extends DataEntity<InvestorCarContract> {

    private static final long serialVersionUID = 1L;
    private String investorCarContractId;        // 资方汽车供需合同ID
    private String investorCarContractCode;        // 编号
    private String investorId;        // 资方
    private Supplier invSupplier;
    private Company companyId;        // 代理公司
    private Date date;        // 订单日期
    private List<InvestorCarContractDetail> investorCarContractDetailList = ListUtils.newArrayList();        // 子表列表
    private InvestorCarContractDetail investorCarContractDetail;
    // 明细合计信息
    private Double calculatePrice1;
    private Double price1;
    private Double amount1;

    public InvestorCarContract() {
        this(null);
    }

    public InvestorCarContract(String id) {
        super(id);
    }

    public String getInvestorCarContractId() {
        return investorCarContractId;
    }

    public void setInvestorCarContractId(String investorCarContractId) {
        this.investorCarContractId = investorCarContractId;
    }

    @Length(min = 0, max = 100, message = "编号长度不能超过 100 个字符")
    public String getInvestorCarContractCode() {
        return investorCarContractCode;
    }

    public void setInvestorCarContractCode(String investorCarContractCode) {
        this.investorCarContractCode = investorCarContractCode;
    }

    @Length(min = 0, max = 64, message = "资方长度不能超过 64 个字符")
    public String getInvestorId() {
        return investorId;
    }

    public void setInvestorId(String investorId) {
        this.investorId = investorId;
    }

    public Company getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Company companyId) {
        this.companyId = companyId;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "订单日期不能为空")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Date getDate_gte() {
        return sqlMap.getWhere().getValue("date", QueryType.GTE);
    }

    public void setDate_gte(Date date) {
        sqlMap.getWhere().and("date", QueryType.GTE, date);
    }

    public Date getDate_lte() {
        return sqlMap.getWhere().getValue("date", QueryType.LTE);
    }

    public void setDate_lte(Date date) {
        sqlMap.getWhere().and("date", QueryType.LTE, date);
    }

    public Date getCreateDate_gte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
    }

    public void setCreateDate_gte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
    }

    public Date getCreateDate_lte() {
        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
    }

    public void setCreateDate_lte(Date createDate) {
        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
    }

    public List<InvestorCarContractDetail> getInvestorCarContractDetailList() {
        return investorCarContractDetailList;
    }

    public void setInvestorCarContractDetailList(List<InvestorCarContractDetail> investorCarContractDetailList) {
        this.investorCarContractDetailList = investorCarContractDetailList;
    }

    public Supplier getInvSupplier() {
        return invSupplier;
    }

    public void setInvSupplier(Supplier invSupplier) {
        this.invSupplier = invSupplier;
    }

    public InvestorCarContractDetail getInvestorCarContractDetail() {
        return investorCarContractDetail;
    }

    public void setInvestorCarContractDetail(InvestorCarContractDetail investorCarContractDetail) {
        this.investorCarContractDetail = investorCarContractDetail;
    }

    public Double getCalculatePrice1() {
        return calculatePrice1;
    }

    public void setCalculatePrice1(Double calculatePrice1) {
        this.calculatePrice1 = calculatePrice1;
    }

    public Double getPrice1() {
        return price1;
    }

    public void setPrice1(Double price1) {
        this.price1 = price1;
    }

    public Double getAmount1() {
        return amount1;
    }

    public void setAmount1(Double amount1) {
        this.amount1 = amount1;
    }
}